package cn.edu.sasu.controller;

import cn.edu.sasu.common.base.LayuiRespResult;
import cn.edu.sasu.common.base.RespResult;
import cn.edu.sasu.common.constants.Constant;
import cn.edu.sasu.domain.dto.SysDoctorDTO;
import cn.edu.sasu.domain.entity.SysDoctor;
import cn.edu.sasu.service.SysDoctorService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 2024/4/27
 *
 * @author ganxue
 */
@RestController
@RequestMapping("/sys_doctor")
public class SysDoctorController {
    @Resource
    private SysDoctorService sysDoctorService;
    @GetMapping("/findSysDoctorAll")
    public LayuiRespResult findDoctorAll(Integer page, Integer limit){
        return sysDoctorService.doctorList(page,limit);
    }
    @GetMapping("/findSysDoctors")
    public RespResult Doctors(){
        List<SysDoctor> deptList=sysDoctorService.getDoctors(Constant.DELETE_FLAG_YES);
        return RespResult.success(deptList);
    }
    @PostMapping("/del")
    public RespResult del(Integer doctorId){
        return sysDoctorService.delSysHospitalByDoctorId(doctorId);
    }

    // 批量删除
    @PostMapping("/batchdel")
    public RespResult batchdel(Integer[] ids){
        return sysDoctorService.batchdel(ids);
    }

    // 搜索
    @GetMapping("/search")
    public LayuiRespResult search(Integer page, Integer limit, String doctorName, String professional, Integer hospitalId, Byte status){
        return sysDoctorService.search(page,limit,doctorName,professional,hospitalId,status);
    }

    // 保存
    @PostMapping("/save")
    public RespResult save(@RequestBody @Validated SysDoctorDTO sysDoctorDTO){
        return sysDoctorService.save(sysDoctorDTO);
    }
    // 更新
    @PostMapping("/update")
    public RespResult update(@RequestBody @Validated SysDoctorDTO sysDoctorDTO){
        return sysDoctorService.update(sysDoctorDTO);
    }}
